/***********************************************************************************
@file   
@attention
***********************************************************************************/
#include "infrared.h"
/***********************************************************************************
 * @brief  
 * @retval
***********************************************************************************/
uint8_t check_code(uint16_t code)
{
    uint8_t a,b,c,d,e;
    a=(code%10000)/1000;
    b=(code%1000)/100;
    c=(code%100)/10;
    d=code%10;
    e=(a+b+c+d)%10;
    return e;
}
/***********************************************************************************
 * @brief  移动上下改变数字
 * @retval direct 0减小，1增加，num 要变化的数，position 坐标
***********************************************************************************/
uint32_t number_change(uint8_t direct,uint32_t num,uint16_t position)
{
    uint8_t k,m;
    uint32_t bb=1;
    
    for(k=0;k<position;k++)
        bb*=10;
    
    m=num/bb%10;
    k=m;
        
    if(direct)
    {
        if(++k>9)
            k=0;
    }
    else
    {
        if(--k==255)
            k=9;
    }
     
    num-=m*bb;
    num+=k*bb;
    
    return num;
}

/***********************************************************************************
 * @brief 数字按位分解
***********************************************************************************/
void number4_break_down(uint32_t data,uint8_t* ary)
{
    ary[0] =  data         / 1000;
	ary[1] = (data % 1000) / 100;
	ary[2] = (data % 100)  / 10;
	ary[3] = (data % 10);   
}
/***********************************************************************************
 * @brief 数字改变 上下限调整
***********************************************************************************/
uint32_t number_change_pos(uint32_t data,uint8_t pos,uint32_t limit_up,uint32_t limit_down)
{
     //--------------------------------------------------------显示密码    
    uint8_t   limit_data[4]  = {0};
    number4_break_down(limit_up,limit_data);
    switch(pos)
    {
        case 1:
        {
            if(data+10>limit_up)
            {
                if(data%10000<(limit_data[0]*1000))
                    data+=1000;
                else
                    data=data-(limit_data[0]*1000);                  
            }
            else
            {
            if(data%1000<(9000))
                data+=100;
            else
                data=data-(9000);         
            }           
        }break;
         case 2:
        {
 
            if(data+10>limit_up)
            {
                if(data%1000<(limit_data[1]*100))
                    data+=100;
                else
                    data=data-(limit_data[1]*100);               
            }
            else
            {
            if(data%1000<(900))
                data+=100;
            else
                data=data-(900);         
            }             
              
        }break;
        case 3:
        {
            
            if(data+10>limit_up)
            {
                if(data%100<(limit_data[2]*10))
                    data+=10;
                else
                    data=data-(limit_data[2]*10);                   
            }
            else
            {
                if(data%100<90)
                    data+=10;
                else
                    data=data-(90);                
            } 
                  
        }break;
        case 4:
        {
            if(data+1>limit_up)
            {
                 if(data%10<(limit_data[3]*1))
                    data+=1;
                else
                    data=data-limit_data[3];                 
            }
            else
            {
                    if(data%10<9)
                    data+=1;
                    else
                    data=data-9;                 
            } 
          
            }break;
        default:break;
    }
    //------------------------------limit
    if(data>limit_up)
        data = limit_up;
    if(data<limit_down)
        data = limit_up;
    return data;
}  
/***********************************************************************************
 * @brief 确定密码进入
 * @param button_infrared_password(password_in);
***********************************************************************************/
void button_infrared_password(uint16_t password)
{
    switch(password) 
    {
        case 1111:  //低报，高报，校零，地址,更改，默认进地址 //1111
            temporary_value_u16=system_data.myaddress;
            page_goto(PAGE_SET_ADDRESS);
            col_flag=0;
            break;
        
         case 1200:  //校零
            page_goto(PAGE_SET_ZERO);
            break; 
         
        case 1112:  //低报
            temporary_value_u16=system_data.low_alarm;
            page_goto(PAGE_SET_LOW);
            col_flag=0;
            break;
        
        case 1113:  //高报
            temporary_value_u16=system_data.high_alarm;
            page_goto(PAGE_SET_HIGH);
            col_flag=0;
            break;       
        
        case 114:  // 活跃线设置 //参数 到达浓度参数后,供电间隔长短
            temporary_value_u16 = system_data.hot_number;
            col_flag = 0;
            page_goto(PAGE_SET_HOT);
            break;
            
        case 911:  // 精度911
            if(system_data.precision == 1)
                temporary_value_u16 = '1';
            else if(system_data.precision == 10)
                temporary_value_u16 = '2';
            else if(system_data.precision == 100)
                temporary_value_u16 = '3';                        
            page_goto(PAGE_SET_PRECISION);
            break;
            
        case 8566:  // 量程，单位//默认进量程
            temporary_value_u16=system_data.unit;
            page_goto(PAGE_SET_UNIT);
            row_flag=1;       
            break;

        case 5430:  //手动设置零点值
            temporary_value_u16=system_data.zero;
            row_flag=0;
            page_goto(PAGE_SET_ZERO_MANUAL);
            break;    
        
        case 5434:  //手动设置跨度值
            temporary_value_u32 = 1;//1为先设置跨度，2为设置adc
            temporary_value_u16_1=system_data.kuadu[0];
            row_flag=1;
            page_goto(PAGE_SET_SPAN_MANUAL);
            break; 
        
        case 369:  // 气体类型-传感器
            temporary_value_u16 = system_data.gastype;
            col_flag = 2;
            page_goto(PAGE_SET_NAME);
            break;
        
        case 689:  // 恢复出场设置
            data_save_init();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break; 
        
        case 68:  // 设置预热时间68
            temporary_value_u16 = system_data.preheating_time;
            row_flag = 1;
            col_flag = 0;
            page_goto(PAGE_SET_PREHEAT);
            break;
            
        case 1235:  // 主机地址 此版本只支持一台主机
            col_flag = 0;
            row_flag = 0;
            temporary_value_u16     = system_data.host_address[0];
            //进入显示当前校验码
            temporary_value_u16_1   = check_code(temporary_value_u16);
            page_goto(PAGE_SET_HOST);            
            break;
        
        case 6001:  // LORA 信道			
            temporary_value_u16=system_data.lora_channel;
            col_flag=0;
            page_goto(PAGE_SET_LORA);				
            break;
        
        case 6002:  // 数据不稳定发包使能		
            temporary_value_u16=system_data.data_stability;
            col_flag=0;
            page_goto(PAGE_SET_LORA_STA);				
            break;           
        
        case 1999:  // 显示ADC
            temporary_value_u16 = adcdata;
            page_goto(PAGE_DIS_ADC);
            break;
            
        case 1101:  // 关机
            row_flag = 0;
            page_goto(PAGE_DIS_SHUT);
            break;

        case 110://防盗灵敏度
        {
            temporary_value_u16=system_data.mobility;
            col_flag=0;
            page_goto(PAGE_SET_MOBILITY);
        }break;
                        
        //角度灵敏度
         case 111:
        {
            temporary_value_u16=system_data.angle_alarm;
            col_flag=0;
            page_goto(PAGE_SET_ANGLE);
        }break;        
            
        case 112:   
            temporary_value_u16 = system_data.speak;
            page_goto(PAGE_SET_SPEAK);
            break;

        case 64:  // 报警时间 60-300
            temporary_value_u16 = system_data.speak_times;
            col_flag = 0;
            page_goto(PAGE_SET_SPEAK_TIMES);
            break;
        
        case 67:  // 报警延迟
            temporary_value_u16 = system_data.alarm_times;
            col_flag = 0;
            page_goto(PAGE_SET_ALARM_TIMES);
            break;
                       
        case 2200:  // 展示低电量报警
            dis_lowpower = 1;
            notic_lowpower = 1;
            page_goto(PAGE_DIS_MAIN);
            row_flag = 0;
            break;
            
        case 61:  // 是否显示电量
            temporary_value_u16 = system_data.energy_flag;
            page_goto(PAGE_SET_ENERGY);
            break;
            
        case 62:  // 满电电量
            temporary_value_u16 = system_data.energy_full;
            page_goto(PAGE_SET_ENERGY_TYPE);
            break;


        case 2288:  // 标定跨度一
            temporary_value_u16_1=0;
            temporary_value_u16=system_data.kuadu[temporary_value_u16_1];
            page_goto(PAGE_SET_SPAN);
            break;
   
        
    #ifdef ANALOG_SENSOR
        case 2258:  // 标定跨度二
            temporary_value_u16_1 = 1;
            temporary_value_u16 = system_data.kuadu[temporary_value_u16_1];
            page_goto(PAGE_SET_SPAN);
            break;
            
        case 2238:  // 标定跨度三
            if(system_data.kuadu[1]) {
                temporary_value_u16_1 = 2;
                temporary_value_u16 = system_data.kuadu[temporary_value_u16_1];
                page_goto(PAGE_SET_SPAN);
            }
            break;
            
        case 2268:  // 清除三段标定
            system_data.kuadu[1] = 0;
            system_data.kuadu[2] = 0;
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS, PAGE_DIS_MAIN, 50);
            break;
            
        case 6969:  // 执行6969
            if(perform_6969())
            {
                dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            }
            else
            {
                dis_dialog(PAGE_DIS_FAIL,PAGE_DIS_MAIN,50);
            }break;
            
            
        case 6868:  // 执行6868
            if(perform_6868())
            {
                dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            }
            else
            {
                dis_dialog(PAGE_DIS_FAIL,PAGE_DIS_MAIN,50);
            }break;

        case 6767:  // 6767
            if(perform_6767())
            {
                dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            }
            else
            {
                dis_dialog(PAGE_DIS_FAIL,PAGE_DIS_MAIN,50);
            }break;
    #endif
            
        default:
            page_goto(PAGE_DIS_MAIN);
            row_flag = 0;
            break;
    }   
}   
/***********************************************************************************
 * @brief 红外按键响应 左
***********************************************************************************/
void infrared_left(void)
{
    lcd_flicker();
    switch(display_page)
    {
        case PAGE_PASSWORD_IN:
        case PAGE_SET_LOW:
        case PAGE_SET_HIGH:
        case PAGE_SET_HOT:
        case 15:
        case 16:    
        case PAGE_SET_RANGE:   
        case PAGE_SET_ZERO_MANUAL:
        case PAGE_SET_SPAN_MANUAL:
        case PAGE_SET_SPAN: if(col_flag==0) col_flag=3;else col_flag--;break;
        
        case PAGE_SET_ADDRESS:
        case PAGE_SET_NAME:
        case PAGE_SET_PREHEAT:
        case PAGE_SET_MOBILITY:
        case PAGE_SET_SPEAK_TIMES:
        case PAGE_SET_POWER_INTERVAL:
                             if(col_flag==0)  col_flag=2; else  col_flag--; break;
        case PAGE_SET_HOST:  if(col_flag==0)  col_flag=4; else  col_flag--; break;
        case PAGE_SET_LORA:
        case PAGE_SET_ANGLE:
        case PAGE_SET_ALARM_TIMES:
                             if(col_flag)     col_flag=0; else col_flag=1;  break;
        default: break;   
    }
}
/***********************************************************************************
 * @brief 红外按键响应 右
***********************************************************************************/
void infrared_right(void)
{
    lcd_flicker();
    switch(display_page)
    {
        case PAGE_PASSWORD_IN:
        case PAGE_SET_LOW:
        case PAGE_SET_HIGH:
        case PAGE_SET_HOT:
        case PAGE_SET_RANGE:
        case PAGE_SET_ZERO_MANUAL:
        case PAGE_SET_SPAN_MANUAL:            
        case PAGE_SET_SPAN:          if(col_flag>=3) col_flag=0;else col_flag++; break;
        case PAGE_SET_ADDRESS:
        case PAGE_SET_NAME:
        case PAGE_SET_PREHEAT:
        case PAGE_SET_MOBILITY:
        case PAGE_SET_SPEAK_TIMES:            
        case PAGE_SET_POWER_INTERVAL:if(col_flag>=2) col_flag=0;else col_flag++; break;
        case PAGE_SET_HOST:          if(col_flag>=4) col_flag=0;else col_flag++;break;
        case 32:                     if(row_flag>=10)row_flag=0;else row_flag++;break;
        case PAGE_SET_LORA:
        case PAGE_SET_ANGLE:
        case PAGE_SET_ALARM_TIMES:   if(col_flag)    col_flag=0;else col_flag=1;break;
        default:break;
    }
}

/***********************************************************************************
 * @brief 红外按键响应 上
***********************************************************************************/
void infrared_up(void)
{
    lcd_no_flicker();
    switch(display_page)
    {
        #ifdef ZHANSHI
        case PAGE_DIS_MAIN:                                             
        {
            temporary_value_u16=10;
            status=6;
            break;
        }
        #endif
        case PAGE_PASSWORD_IN:
        {   
            password_in=number_change(1,password_in,3-col_flag);
            break;
        }
        case PAGE_SET_PRECISION:
        {
            if((temporary_value_u16=='1')||(temporary_value_u16=='2'))
                temporary_value_u16++;
            else
                temporary_value_u16='1';
             break;
        }
        case PAGE_SET_HOT:
        {
//             temporary_value_u16 = number_change_pos(temporary_value_u16,col_flag+1,system_data.range_ability,0);  
            temporary_value_u16=number_change(1,temporary_value_u16,3-col_flag);
            if(temporary_value_u16>system_data.range_ability)
                temporary_value_u16=0;
            break;
        }
        case 8:
        {
            if(temporary_value_u16<2)
                temporary_value_u16++;
            else
                temporary_value_u16=1;
            break;
        } 

        case PAGE_SET_ADDRESS:
        case PAGE_SET_NAME:
        {
            temporary_value_u16 = number_change_pos(temporary_value_u16,col_flag+2,128,0);
            break;
        }
        case 10:
        {
            if(temporary_value_u16==9600)
                temporary_value_u16=4800;
            else
                temporary_value_u16=9600;
            break;
        }
        case PAGE_SET_LOW:
        {
//            temporary_value_u16 = number_change_pos(temporary_value_u16,col_flag+1,system_data.high_alarm,0);  
            temporary_value_u16=number_change(1,temporary_value_u16,3-col_flag);        
            if(temporary_value_u16>system_data.high_alarm)
                temporary_value_u16=0;
            
            if(temporary_value_u16<5)
                temporary_value_u16=5;           
            break;
        }
        case PAGE_SET_HIGH:
        {
//             temporary_value_u16 = number_change_pos(temporary_value_u16,col_flag+1,system_data.range_ability,system_data.low_alarm);  
            temporary_value_u16=number_change(1,temporary_value_u16,3-col_flag);
            if(temporary_value_u16<system_data.low_alarm)
                temporary_value_u16=system_data.low_alarm;      
            if(temporary_value_u16>system_data.range_ability)
                temporary_value_u16=system_data.low_alarm;
            break;
        }
        case PAGE_SET_NEGATIVE:
        case PAGE_SET_SPEAK:
        case PAGE_SET_ENERGY:    
        {
            if(temporary_value_u16)
                temporary_value_u16=0;
            else
                temporary_value_u16=1;
            break;
        }
        case PAGE_SET_ENERGY_TYPE:    
        {
            if(temporary_value_u16==4000)
                temporary_value_u16=3600;
            else
                temporary_value_u16=4000;
            break;
        }
        
        case PAGE_SET_ZERO_MANUAL:
        {
//             temporary_value_u16 = number_change_pos(temporary_value_u16,col_flag+1,4095,0);  
            temporary_value_u16=number_change(1,temporary_value_u16,3-col_flag);
            if(temporary_value_u16>4095)
                temporary_value_u16=0;//4095
            break; 
        }

        case PAGE_SET_SPAN_MANUAL: 
        {     
            if(temporary_value_u32==1)//跨度
            {
//                temporary_value_u16 = number_change_pos(temporary_value_u16,col_flag+1,system_data.range_ability,0); 
                temporary_value_u16_1=number_change(1,temporary_value_u16_1,3-col_flag);
                if(temporary_value_u16_1>system_data.range_ability)
                    temporary_value_u16_1=0;            
            }
            else//adc
            {
//                temporary_value_u16 = number_change_pos(temporary_value_u16,col_flag+1,system_data.range_ability,0);                 
                temporary_value_u16=number_change(1,temporary_value_u16,3-col_flag);
                if(temporary_value_u16>4095)
                    temporary_value_u16=0;//4095                          
            }
            break;
        }    
        case PAGE_SET_SPAN:                                        //跨度一
        {
//            temporary_value_u16 = number_change_pos(temporary_value_u16,col_flag+1,system_data.range_ability,0);                 
            temporary_value_u16=number_change(1,temporary_value_u16,3-col_flag);
            if(temporary_value_u16>system_data.range_ability)
                temporary_value_u16=0;
            break;
        }
        case PAGE_SET_HOST:
        {
            switch(col_flag)
            {
                case 0:
                case 1:
                case 2:
                case 3:
                {
                    temporary_value_u16=number_change(1,temporary_value_u16,3-col_flag);
                    break;
                   
                }
                case 4:
                {
                    if(temporary_value_u16_1>=9)
                        temporary_value_u16_1=0;
                    else
                        temporary_value_u16_1+=1;
                    break;
                }
            }
            break;
        }
        case 24:
        {
            if(temporary_value_u16>=8)
                temporary_value_u16=3;
            else
                temporary_value_u16++;
            break;
        }
        case PAGE_SET_LORA_STA:        
        case PAGE_SET_UNIT:
        {
            if(temporary_value_u16<10)
                temporary_value_u16++;
            else
                temporary_value_u16=1;
            break;
        }
        case PAGE_SET_RANGE:
        {
            temporary_value_u16=number_change(1,temporary_value_u16,3-col_flag);
            break;
        }
        case PAGE_SET_LORA:
        {
            temporary_value_u16=number_change(1,temporary_value_u16,1-col_flag);
            if(temporary_value_u16>15)
            {
                temporary_value_u16=0;
            }
            break;
        }
        case PAGE_SET_ALARM_TIMES:
        {
            temporary_value_u16=number_change(1,temporary_value_u16,1-col_flag);
            if(temporary_value_u16>99)
            {
                temporary_value_u16=0;
            }
            if(temporary_value_u16<1)
            {
                temporary_value_u16=1;
            }
            break;
        }
        
        case PAGE_SET_SPEAK_TIMES:
        {
            temporary_value_u16=number_change(1,temporary_value_u16,2-col_flag);
            if(temporary_value_u16>300)
            {
                temporary_value_u16=0;
            }
            if(temporary_value_u16<60)
            {
                temporary_value_u16=60;
            }
            break;
        }        
     
        case PAGE_SET_MOBILITY:
        {
            temporary_value_u16=number_change(1,temporary_value_u16,2-col_flag);
            if(temporary_value_u16>255)
                temporary_value_u16=0;
            break;
        }
        
        case PAGE_SET_ANGLE:
        {
            temporary_value_u16=number_change(1,temporary_value_u16,1-col_flag);
            if(temporary_value_u16>99)
            {
                temporary_value_u16=99;
            }
            break;
        }        
        
        case 80:
        {
            if(temporary_value_u16<5)
                temporary_value_u16++;
            else
                temporary_value_u16=0;
            break;
        } 
        case PAGE_SET_PREHEAT:
        {
            temporary_value_u16=number_change(1,temporary_value_u16,2-col_flag);
            if(temporary_value_u16>100)
            {
                temporary_value_u16=0;
            }
            else
            if(temporary_value_u16<10)
            {
                temporary_value_u16=10;
            }
            break;
        }
        case PAGE_SET_POWER_INTERVAL:
        {
            temporary_value_u16=number_change(1,temporary_value_u16,2-col_flag);
            if(temporary_value_u16>180)
            {
                temporary_value_u16=0;
            }
            else
            if(temporary_value_u16<10)
            {
                temporary_value_u16=10;
            }
            break;
        }
        case PAGE_DIS_SHUT:
        {
            if(row_flag)
            {
                row_flag=0;
            }
            else
            {
                row_flag=1;
            }
            break;
        }
        default:
        {
            break;
        }
    
    }
}

/***********************************************************************************
 * @brief 红外按键响应 下
***********************************************************************************/
void infrared_down(void)
{
    lcd_no_flicker();
    switch(display_page)
    {
        #ifdef ZHANSHI
        case PAGE_DIS_MAIN:                                             
        {
            power_low1=1;
            break;
        }
        #endif
        case PAGE_PASSWORD_IN:
        {  
            password_in=number_change(0,password_in,3-col_flag);
            break;
        }
        case PAGE_SET_PRECISION:
        {
            if((temporary_value_u16=='2')||(temporary_value_u16=='3'))
                temporary_value_u16--;
            else temporary_value_u16='3';
            break;
        }
        case PAGE_SET_HOT:
        {
            temporary_value_u16=number_change(0,temporary_value_u16,3-col_flag);
            if(temporary_value_u16>system_data.range_ability)
                temporary_value_u16=system_data.range_ability;
            break;
        }
        case 8:
        {
            if(temporary_value_u16<=1)
                temporary_value_u16=2;
            else
                temporary_value_u16--;
            break;
        }
        case PAGE_SET_ADDRESS:
        case PAGE_SET_NAME:
        {
            temporary_value_u16=number_change(0,temporary_value_u16,2-col_flag);
            if(temporary_value_u16>128)
                temporary_value_u16=128;
            break;
        }
        case 10:
        {
            if(temporary_value_u16==4800)
                temporary_value_u16=9600;
            else
                temporary_value_u16=4800;
            break;
        }
        case PAGE_SET_LOW:
        {
            temporary_value_u16=number_change(0,temporary_value_u16,3-col_flag);
            if(temporary_value_u16>system_data.high_alarm)
                temporary_value_u16=system_data.high_alarm;
            if(temporary_value_u16<5)
                temporary_value_u16=5;   
            break;
        }
        case PAGE_SET_HIGH:
        {
            temporary_value_u16=number_change(0,temporary_value_u16,3-col_flag);
            if(temporary_value_u16<system_data.low_alarm)
                temporary_value_u16=system_data.low_alarm;
            if(temporary_value_u16>system_data.range_ability)
                temporary_value_u16=system_data.low_alarm;
            break;
        }
        
        case PAGE_SET_SPAN_MANUAL: 
        {     
            if(temporary_value_u32==1)//跨度
            {
                temporary_value_u16_1=number_change(0,temporary_value_u16_1,3-col_flag);
                if(temporary_value_u16_1>system_data.range_ability)
                    temporary_value_u16_1=system_data.range_ability;            
            }
            else//adc
            {
                temporary_value_u16=number_change(0,temporary_value_u16,3-col_flag);
                if(temporary_value_u16>4095)
                    temporary_value_u16=4095;                           
            }
            break;
        }  
        
        case PAGE_SET_HOST:
        {
            switch(col_flag)
            {
                case 0:
                case 1:
                case 2:
                case 3:
                {
                    temporary_value_u16=number_change(0,temporary_value_u16,3-col_flag);
                    break;
                }
                case 4:
                {
                    if(temporary_value_u16_1==0)
                        temporary_value_u16_1=9;
                    else
                        temporary_value_u16_1-=1;
                    break;
                }
            }
            break;
        }

        case PAGE_SET_SPAN:                                      				  //跨度一
        {
            temporary_value_u16=number_change(0,temporary_value_u16,3-col_flag);
            if(temporary_value_u16>system_data.range_ability)
                temporary_value_u16=system_data.range_ability;
            break;
        }
        case PAGE_SET_NEGATIVE:
        case PAGE_SET_SPEAK:
        case PAGE_SET_ENERGY:  
        {
            if(temporary_value_u16)
                temporary_value_u16=0;
            else
                temporary_value_u16=1;
            break;
        }
        case PAGE_SET_ENERGY_TYPE:    
        {
            if(temporary_value_u16==4000)
                temporary_value_u16=3600;
            else
                temporary_value_u16=4000;
            break;
        }
        case PAGE_SET_ZERO_MANUAL:
        {
            temporary_value_u16=number_change(0,temporary_value_u16,3-col_flag);
            if(temporary_value_u16>4095)
                temporary_value_u16=4095;
            break;
        }
        case 201:
        {
            switch(row_flag)
            {
                case 1:
                {
                    if(temporary_value_u16%10000>=1000)
                        temporary_value_u16-=1000;
                    else
                        temporary_value_u16=temporary_value_u16+10000-1000;
                    break;
                }
                case 2:
                {
                    if(temporary_value_u16%1000>=100)
                        temporary_value_u16-=100;
                    else
                        temporary_value_u16=temporary_value_u16+1000-100;
                    break;
                }
                case 3:
                {
                    if(temporary_value_u16%100>=10)
                        temporary_value_u16-=10;
                    else
                        temporary_value_u16=temporary_value_u16+100-10;
                    break;
                }
                case 4:
                {
                    if(temporary_value_u16%10>0)
                        temporary_value_u16-=1;
                    else
                        temporary_value_u16=temporary_value_u16+10-1;
                    break;
                }
                default:
                {
                    break;
                }
            }
            if(temporary_value_u16>4095)
                temporary_value_u16=0;
            break;
        }
        case 24:
        {
            if(temporary_value_u16<=3)
                temporary_value_u16=8;
            else
                temporary_value_u16--;
            break;
        }
        case PAGE_SET_LORA_STA:
        case PAGE_SET_UNIT:
        {
            if(temporary_value_u16<=1)
                temporary_value_u16=10;
            else
                temporary_value_u16--;
            break;
        }
        case PAGE_SET_RANGE:
        {
            temporary_value_u16=number_change(0,temporary_value_u16,3-col_flag);
            break;
        }
        case PAGE_SET_MOBILITY:
        {
            temporary_value_u16=number_change(0,temporary_value_u16,2-col_flag);
            if(temporary_value_u16>255)
                temporary_value_u16=255;
            break;
        }
        case PAGE_SET_ANGLE:
        {
            temporary_value_u16=number_change(0,temporary_value_u16,1-col_flag);
            if(temporary_value_u16>99)
            {
                temporary_value_u16=99;
            }
            break;
        }        
        
        case PAGE_SET_LORA:
        {
            temporary_value_u16=number_change(0,temporary_value_u16,1-col_flag);
            if(temporary_value_u16>15)
            {
                temporary_value_u16=15;
            }
            break;
        }
        case PAGE_SET_ALARM_TIMES:
        {
            temporary_value_u16=number_change(0,temporary_value_u16,1-col_flag);
            if(temporary_value_u16>99)
            {
                temporary_value_u16=99;
            }
            if(temporary_value_u16<1)
            {
                temporary_value_u16=1;
            }
            break;
        }
 
        
        case PAGE_SET_SPEAK_TIMES:
        {
            temporary_value_u16=number_change(0,temporary_value_u16,2-col_flag);
            if(temporary_value_u16>300)
            {
                temporary_value_u16=0;
            }
            if(temporary_value_u16<60)
            {
                temporary_value_u16=60;
            }
            break;
        }
        
        
        
        case 80:
        {
            if(temporary_value_u16==0)
                temporary_value_u16=5;
            else
                temporary_value_u16--;
            break;
        }
        case PAGE_SET_PREHEAT:
        {
            temporary_value_u16=number_change(0,temporary_value_u16,2-col_flag);
            if(temporary_value_u16>100)
            {
                temporary_value_u16=0;
            }
            else
            if(temporary_value_u16<10)
            {
                temporary_value_u16=10;
            }
            break;
        }
        case PAGE_SET_POWER_INTERVAL:
        {
            temporary_value_u16=number_change(0,temporary_value_u16,2-col_flag);
            if(temporary_value_u16>180)
            {
                temporary_value_u16=180;
            }
            else
            if(temporary_value_u16<10)
            {
                temporary_value_u16=10;
            }
            break;
        }
        case PAGE_DIS_SHUT:
        {
            if(row_flag)
            {
                row_flag=0;
            }
            else
            {
                row_flag=1;
            }
            break;
        }
        default:
        {
            break;
        }
    }
}
/***********************************************************************************
 * @brief 红外按键响应 确定
***********************************************************************************/
void infrared_ok(void)
{
    uint16_t m;
    switch(display_page)
    {
        case PAGE_PASSWORD_IN:
        {
            if(gate_in==1)
            {
                button_infrared_password(password_in);
            }
            else if(gate_in==2)
            {
                //进入测试状态
                if((password_in==1100)&&(status<3))
                {   
                    test_num=10;
                    status=6;
                }
                page_goto(PAGE_DIS_MAIN);
            }else if(gate_in==3)//实体按键功能/测试
            {
                //进入测试状态
                if((password_in==1100)&&(status<3))
                {   
                    test_num=10;
                    status=6;
                    page_goto(PAGE_DIS_MAIN);
                }
                else
                {
                    button_infrared_password(password_in);
                }
            }
            gate_in=0;
            break;
        }
        case PAGE_SET_NAME:
        {
            system_data.gastype=temporary_value_u16;
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        }
        case PAGE_SET_PRECISION:
        {
            if(temporary_value_u16=='1')
                system_data.precision=1;
            else if(temporary_value_u16=='2')
                system_data.precision=10;
            else if(temporary_value_u16=='3')
                 system_data.precision=100;
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        }
        case PAGE_SET_ADDRESS:
        {
            system_data.myaddress=temporary_value_u16;
            time_send_lora=0;
            data_save();
            row_flag=4;
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        }
        //--确定设置跨度
        
        case PAGE_SET_SPAN_MANUAL: 
        {
            
            if(temporary_value_u32==2)
            {
                system_data.adc[0] = temporary_value_u16;
                data_save();
                dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            }
                   
            if(temporary_value_u32==1)
            {
                system_data.kuadu[0]=temporary_value_u16_1;
                data_save();
                temporary_value_u32=2; 
                temporary_value_u16 =system_data.adc[0];
                row_flag=1;
                col_flag=0; 
           
            }

            break;
        }    
        
        case PAGE_SET_NEGATIVE:
        {
            system_data.negative=temporary_value_u16;
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        }          
        case PAGE_SET_HOT:
        {
            system_data.hot_number=temporary_value_u16;
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        }                
        case PAGE_SET_LOW:
        {
            system_data.low_alarm=temporary_value_u16;
            if(temporary_value_u16>system_data.high_alarm)
                temporary_value_u16=system_data.high_alarm;
            if(temporary_value_u16<5)
                temporary_value_u16=5;   
            
            data_save();
            row_flag=1;
            page_goto(PAGE_DIS_MAIN);;
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        }
        case PAGE_SET_HIGH: 
        {
            if(temporary_value_u16<system_data.low_alarm)
                temporary_value_u16=system_data.low_alarm;      
            if(temporary_value_u16>system_data.range_ability)
                temporary_value_u16=system_data.range_ability;
            
            system_data.high_alarm=temporary_value_u16;
            data_save();
            row_flag=2;
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        }
        case PAGE_SET_ZERO:
        {
            row_flag=3;
            temporary_value_u16=0;
            system_data.zero=adcdata+10;
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        }
               
        case PAGE_SET_ZERO_MANUAL:
        {
            system_data.zero=temporary_value_u16;
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        }
        
        case PAGE_SET_ENERGY:
        {
            system_data.energy_flag=temporary_value_u16;
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        } 
        case PAGE_SET_LORA_STA:
        {
            system_data.data_stability=temporary_value_u16;
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        }         
             
        case PAGE_SET_ENERGY_TYPE:
        {
            system_data.energy_full=temporary_value_u16;
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        }                  

        case PAGE_SET_SPAN:                                        //跨度
        {
            sleep_device_operation_time(SPAN_WAKEUP_TIME); 
            page_goto(PAGE_SET_CAL);
            break;
        }
        case PAGE_SET_HOST:
        {
            if(check_code(temporary_value_u16)==temporary_value_u16_1)
            {
                system_data.host_address[0]=temporary_value_u16;
                time_send_lora=0;
                data_save();
                dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            }
            else
            {
                dis_dialog(PAGE_DIS_FAIL,PAGE_DIS_MAIN,50);
            }
            break;
        }
        case 23:
        {
            page_goto(PAGE_DIS_MAIN);
            break;
        }
        case PAGE_SET_UNIT:
        {
            system_data.unit=temporary_value_u16;
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            row_flag=1;
            break;
        }
        case PAGE_SET_RANGE:
        {
            system_data.range_ability=temporary_value_u16;
            if(system_data.high_alarm>system_data.range_ability)
            {
                system_data.high_alarm=temporary_value_u16;
            }
            if(system_data.low_alarm>system_data.high_alarm)
            {
                system_data.low_alarm=system_data.high_alarm;
            }
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            row_flag=2;
            break;
        }
        case PAGE_SET_LORA:
        {
            system_data.lora_channel=temporary_value_u16;
            lora_init();
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        }
        case PAGE_SET_SPEAK:
        {
            system_data.speak=temporary_value_u16;
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        }
        case PAGE_SET_MOBILITY:
        {
            system_data.mobility=temporary_value_u16;
            if(adxl345_init())
            {
                dis_dialog(PAGE_DIS_FAIL,PAGE_DIS_MAIN,50);
            }
            else
            {
                data_save();
                dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            }
            break;
        }
        
        case PAGE_SET_ANGLE:
        {
            system_data.angle_alarm=temporary_value_u16;
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        }        
        
        
        case PAGE_SET_ALARM_TIMES:
        {
            system_data.alarm_times=temporary_value_u16;
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        }
        case PAGE_SET_SPEAK_TIMES:
        {
            system_data.speak_times=temporary_value_u16;
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        }        
        
        case PAGE_SET_PREHEAT:
        {
            system_data.preheating_time=temporary_value_u16;
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        }
        case PAGE_SET_POWER_INTERVAL:
        {
            system_data.power_interval=temporary_value_u16*100;
            data_save();
            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
            break;
        }
        case PAGE_DIS_SHUT:
        {
            if(row_flag)
            {
                lora_send_message(1);
                delay_ms(700);
                bat_en(0);
            }
            page_goto(PAGE_DIS_MAIN);
            break;
        }
        case PAGE_SET_CAL:                                       //标定 2288
        {
            m=10;
            sleep_device_update_time(IR_NORMAL_TIME);
            switch(temporary_value_u16_1)
            {
                case 0:
                {
                    #ifdef ANALOG_SENSOR
                    m=10;
                    if(system_data.kuadu[1])
                    {
                        if((temporary_value_u16)<system_data.kuadu[1])
                        {
                            if((adcdata>system_data.zero)&&(system_data.adc[1]>adcdata)&&(temporary_value_u16>0))
                            {
                                system_data.adc[0]=adcdata;
                                system_data.kuadu[0]=temporary_value_u16;
                                data_save();
                                
                                dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
                             }
                            else
                            {
                                
                                dis_dialog(PAGE_DIS_FAIL,PAGE_DIS_MAIN,50);
                            }
                        }
                        else
                        {
                            system_data.kuadu[1]=0;
                            system_data.kuadu[2]=0;
                            if((adcdata>system_data.zero)&&(temporary_value_u16>0))
                            {
                                system_data.adc[0]=adcdata;
                                system_data.kuadu[0]=temporary_value_u16;
                                data_save();
                                
                                dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
                             }
                             else
                             {
                                 
                                 dis_dialog(PAGE_DIS_FAIL,PAGE_DIS_MAIN,50);
                             }
                        }
                    }
                    else
                    {
                        if((adcdata>system_data.zero)&&(temporary_value_u16>0))//system_data.kuadu[0]
                        {
                            system_data.adc[0]=adcdata;
                            system_data.kuadu[0]=temporary_value_u16;
                            data_save();
                            
                            dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
                         }
                        else
                        {
                            
                            dis_dialog(PAGE_DIS_FAIL,PAGE_DIS_MAIN,50);
                        }
                    }
                    #else
                    temporary_value_u32=0;
                    page_goto(PAGE_DIS_WAIT_CAL);
                    page_dis_wait_cal();
                    DisplayGraph();
                    
                    if(sensor_set(4,temporary_value_u16,2,20))
                    {
                        HAL_Delay(100);
                        if(sensor_set(5,0,2,20))
                        {
                            HAL_Delay(300);
                            if(sensor_set(6,0,2,20))
                            {
                                HAL_Delay(2000);
                                if(sensor_set(7,0,2,20))
                                {
                                    temporary_value_u32=1;
                                    system_data.kuadu[0]=temporary_value_u16;
                                    data_save();
                                }
                            }
                        }
                    }
                    if(temporary_value_u32)
                    {
                        dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);
                    }
                    else
                    {
                        dis_dialog(PAGE_DIS_FAIL,PAGE_DIS_MAIN,50);
                    }
                    #endif
                    break;
                }
                case 1:
                {
                    if(temporary_value_u16==0)
                    {
                        system_data.kuadu[1]=temporary_value_u16;
                        data_save();
                        
                        dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);;
                    }
                    else
                    {
                        if(system_data.kuadu[2])
                        {
                            if(temporary_value_u16<system_data.kuadu[2])
                            {
                                if((adcdata>system_data.adc[0])&&(adcdata<system_data.adc[2])&&(temporary_value_u16>system_data.kuadu[0]))
                                {
                                    system_data.adc[1]=adcdata;
                                    system_data.kuadu[1]=temporary_value_u16;
                                    data_save();
                                    
                                    dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);;
                                 }
                                else
                                {
                                    
                                    dis_dialog(PAGE_DIS_FAIL,PAGE_DIS_MAIN,50);
                                }
                            }
                            else
                            {
                                system_data.kuadu[2]=0;
                                if((adcdata>system_data.adc[0])&&(temporary_value_u16>system_data.kuadu[0]))
                                {
                                    system_data.adc[1]=adcdata;
                                    system_data.kuadu[1]=temporary_value_u16;
                                    data_save();
                                    
                                    dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);;
                                 }
                                else
                                {
                                    
                                    dis_dialog(PAGE_DIS_FAIL,PAGE_DIS_MAIN,50);
                                }
                            }
                           
                        }
                        else
                        {
                            if((adcdata>system_data.adc[0])&&(temporary_value_u16>system_data.kuadu[0]))
                            {
                                system_data.adc[1]=adcdata;
                                system_data.kuadu[1]=temporary_value_u16;
                                data_save();
                                
                                dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);;
                             }
                            else
                            {
                                
                                dis_dialog(PAGE_DIS_FAIL,PAGE_DIS_MAIN,50);
                            }
                        }
                    }
                    break;
                }
                case 2:
                {
                    if(((adcdata>system_data.adc[1])&&(temporary_value_u16>system_data.kuadu[1]))||(temporary_value_u16==0))
                    {
                        system_data.adc[2]=adcdata;
                        system_data.kuadu[2]=temporary_value_u16;
                        data_save();
                        
                        dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);;
                     }
                    else
                    {
                        
                        dis_dialog(PAGE_DIS_FAIL,PAGE_DIS_MAIN,50);
                    }
                    break;
                }
            }
            break;
        }
        case 201:
        {
            if(temporary_value_u16>system_data.zero)
            {
                  system_data.adc[0]=temporary_value_u16;
                  system_data.kuadu[0]=temporary_value_u16_1;
                  data_save();
                  dis_dialog(PAGE_DIS_SUCCESS,PAGE_DIS_MAIN,50);;
             }
            else
                dis_dialog(PAGE_DIS_FAIL,PAGE_DIS_MAIN,50);
                
            break;
        }
        case PAGE_DIS_WAIT_CAL:
        case PAGE_DIS_6969:
        case PAGE_DIS_6868:
        {
            break;
        }
        default:
        {
            
            page_goto(PAGE_DIS_MAIN);
            break;
        }

    }
}


/***********************************************************************************
 * @brief 红外按键响应 返回
***********************************************************************************/
void infrared_quit(void)
{
    switch(display_page)
    {
        case PAGE_PASSWORD_IN:
        case PAGE_DIS_CAL:
        case PAGE_SET_NAME:
        case PAGE_SET_PRECISION:
        case 8:
        case 9:
        case 10:
        case PAGE_DIS_LOW:
        case PAGE_DIS_HIGH:
        case PAGE_DIS_RANGE:
        case PAGE_DIS_KUADU:
        case PAGE_DIS_UNIT:
        case PAGE_DIS_SUCCESS:
        case PAGE_DIS_FAIL:
        case PAGE_SET_LORA_STA:            
        case 80:page_goto(PAGE_DIS_MAIN);break;
        case PAGE_SET_LOW:row_flag=1;page_goto(PAGE_DIS_MAIN);break;
        case PAGE_SET_HIGH:row_flag=2;page_goto(PAGE_DIS_MAIN);break;
        case PAGE_SET_ZERO:row_flag=3;page_goto(PAGE_DIS_MAIN);break;
        case PAGE_SET_ADDRESS:row_flag=4;page_goto(PAGE_DIS_MAIN);break;
        case PAGE_SET_SPAN:row_flag=1;page_goto(PAGE_DIS_MAIN);break;
        case 51:page_goto(PAGE_DIS_MAIN);break;
        case 52:row_flag=2;page_goto(PAGE_DIS_MAIN);break;
        case PAGE_SET_CAL:row_flag=1;page_goto(PAGE_DIS_CAL);sleep_device_update_time(IR_NORMAL_TIME);break;
        case PAGE_DIS_6969:
        case PAGE_DIS_6868:
        case PAGE_DIS_WAIT_CAL:break;
        case PAGE_DIS_MAIN:if(status==6)status=0;break;
        default:page_goto(PAGE_DIS_MAIN);row_flag=0; break;
    }
}
/***********************************************************************************
 * @brief 红外按键响应 功能
***********************************************************************************/
void infrared_func(void)
{
    if(display_page==PAGE_DIS_MAIN)
    {
        gate_in=1;
        page_goto(PAGE_PASSWORD_IN);
        col_flag=0;
        row_flag=0;
    }
}
/***********************************************************************************
 * @brief 红外按键响应 地址
***********************************************************************************/
void infrared_addr(void)
{
    //--------------------------------取消遥控器的地址按键切换主机地址
//    if(display_page==PAGE_SET_HOST)
//    {
//        if(row_flag<4) row_flag++;
//        else           row_flag=0;
//        temporary_value_u16=system_data.host_address[row_flag];
//        temporary_value_u16_1=check_code(system_data.host_address[row_flag]);
//    }
    //--------------------------------系统设置参数可以任意跳跃
    if(display_page==PAGE_SET_LOW||\
       display_page==PAGE_SET_HIGH||\
       display_page==PAGE_SET_ZERO||\
       display_page==PAGE_SET_ADDRESS)
    {
        temporary_value_u16=system_data.myaddress;
        page_goto(PAGE_SET_ADDRESS);
        col_flag=0;
    }
    //--------------------------------显示地址数值
    if(display_page==PAGE_DIS_MAIN)
    {
        page_goto(PAGE_DIS_ADDR);
    }  
    
}
/***********************************************************************************
 * @brief 红外按键响应 校零
***********************************************************************************/
void infrared_zero(void)
{
    if(display_page==PAGE_DIS_MAIN)
    {
        page_goto(PAGE_DIS_ZERO);
    }
     //--------------------------------系统设置2 参数可以任意跳跃
    if(display_page==PAGE_SET_LOW||\
       display_page==PAGE_SET_HIGH||\
       display_page==PAGE_SET_ZERO||\
       display_page==PAGE_SET_ADDRESS)
    {
        page_goto(PAGE_SET_ZERO);
    }
}
/***********************************************************************************
 * @brief 红外按键响应 单位
***********************************************************************************/
void infrared_unit(void)
{
    if(display_page==PAGE_DIS_MAIN)
    {
        page_goto(PAGE_DIS_UNIT);
    }
    //--------------------------------系统设置2 参数可以任意跳跃
    if(display_page==PAGE_SET_UNIT||\
       display_page==PAGE_SET_RANGE)
    { 
        temporary_value_u16=system_data.unit;
        page_goto(PAGE_SET_UNIT);
        row_flag=1; 
    }
}
/***********************************************************************************
 * @brief 红外按键响应 消音
***********************************************************************************/
void infrared_mute(void)
{
    if((status==1)||(status==2)) xiaoyin=1;     
}   
/***********************************************************************************
 * @brief 红外按键响应 低报
***********************************************************************************/
void infrared_low(void)
{
    if(display_page==PAGE_DIS_MAIN)
    {
        page_goto(PAGE_DIS_LOW);
    }
    //--------------------------------系统设置参数可以任意跳跃
    if(display_page==PAGE_SET_LOW||\
       display_page==PAGE_SET_HIGH||\
       display_page==PAGE_SET_ZERO||\
       display_page==PAGE_SET_ADDRESS)
    {
        temporary_value_u16=system_data.low_alarm;
        page_goto(PAGE_SET_LOW);
        col_flag=0;
    }
} 
/***********************************************************************************
 * @brief 红外按键响应 高报
***********************************************************************************/
void infrared_high(void)
{
    if(display_page==PAGE_DIS_MAIN)
    {
        page_goto(PAGE_DIS_HIGH);
    }
    //--------------------------------系统设置参数可以任意跳跃
    if(display_page==PAGE_SET_LOW||\
       display_page==PAGE_SET_HIGH||\
       display_page==PAGE_SET_ZERO||\
       display_page==PAGE_SET_ADDRESS)
    {
        temporary_value_u16=system_data.high_alarm;
        page_goto(PAGE_SET_HIGH);
        col_flag=0;
    }    
} 
/***********************************************************************************
 * @brief 红外按键响应 量程
***********************************************************************************/
void infrared_range(void)
{
    if(display_page==PAGE_DIS_MAIN)
    {
        page_goto(PAGE_DIS_RANGE);
    }   
    //--------------------------------系统设置2 参数可以任意跳跃
    if(display_page==PAGE_SET_UNIT||\
       display_page==PAGE_SET_RANGE)
    { 
    temporary_value_u16=system_data.range_ability;
            page_goto(PAGE_SET_RANGE);
            row_flag=1;
    }
 
            
}     
/***********************************************************************************
 * @brief 红外按键响应 跨度 循环显示数组
***********************************************************************************/
void infrared_kuadu(void)
{
    if(display_page==PAGE_DIS_KUADU)//
    {
        temporary_value_u16++;
        if(temporary_value_u16==6)
            temporary_value_u16 = 0;
    }
    
    if(display_page==PAGE_DIS_MAIN)
    {   
        temporary_value_u16 = 0;
        page_goto(PAGE_DIS_KUADU);
    }
}     
/***********************************************************************************
 * @brief 红外按键响应 测试
***********************************************************************************/
void infrared_test(void)
{
    if(display_page==PAGE_DIS_MAIN)
    {
        gate_in=2;
        page_goto(PAGE_PASSWORD_IN);
        col_flag=0;
        row_flag=0;
    }
}     
/***********************************************************************************
 * @brief 红外按键响应 标定
***********************************************************************************/
void infrared_cali(void)
{
    if(display_page==PAGE_DIS_CAL)//
    {
        temporary_value_u16++;
        if(temporary_value_u16==3)
            temporary_value_u16 = 0;
    }
    if(display_page==PAGE_DIS_MAIN)
    {   
        temporary_value_u16 = 0;
        page_goto(PAGE_DIS_CAL);
    }
}  
/***********************************************************************************
 * @brief 红外按键响应 精度
***********************************************************************************/
void infrared_prec(void)
{
    if(display_page==PAGE_DIS_MAIN)
    {
        page_goto(PAGE_DIS_PRECISION);
    }
}  

/***********************************************************************************
 * @brief 红外按键响应 功能
***********************************************************************************/
void button_func(void)
{
    if(display_page==PAGE_DIS_MAIN)
    {
        gate_in=3;//更改密码入口 兼容
        page_goto(PAGE_PASSWORD_IN);
        col_flag=0;
        row_flag=0;
    }
}

/***********************************************************************************
 * @brief 按键流程
***********************************************************************************/
void infrared_total(uint8_t value)
{
	activity=0;
	dead_time=0;
    key = value;
    switch (key)
    {
        case KEY_UNIT:  infrared_unit();   break;//单位
        case KEY_ADDR:  infrared_addr();   break;//地址
        case KEY_ZERO:  infrared_zero();   break;//校零                                      
        case KEY_FUNC:  infrared_func();   break;//功能
        case KEY_QUIT:  infrared_quit();   break;//返回                                           
        case KEY_OK:    infrared_ok();     break;//OK
        case KEY_LEFT:  infrared_left();   break;//左
        case KEY_RIGHT: infrared_right();  break;//右
        case KEY_UP:    infrared_up();     break;//上
        case KEY_DOWN:  infrared_down();   break;//下
        case KEY_MUTE:  infrared_mute();   break;//消音
        case KEY_LOW:   infrared_low();    break;//低报
        case KEY_HIGH:  infrared_high();   break;//高报
        case KEY_RANGE: infrared_range();  break;//量程
        case KEY_KUADU: infrared_kuadu();  break;//跨度
		case KEY_TEST:  infrared_test();   break;//测试
        case KEY_CALI:  infrared_cali();   break;//标定
        case KEY_PREC:  infrared_prec();   break;//精度      

        case BUT_FUNC:  button_func();     break;//添加实体按键 功能兼并测试       
		default:break;       
    }
}
